-
-
Notifications
You must be signed in to change notification settings - Fork 18k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
DEPR: datetimelike.astype(int) #38544
Conversation
can you merge master |
doc/source/whatsnew/v1.3.0.rst
Outdated
@@ -142,7 +142,7 @@ Other API changes | |||
|
|||
Deprecations | |||
~~~~~~~~~~~~ | |||
|
|||
- Deprecated casting of datetimelike (``timedelta64[ns]``, ``datetime64[ns]``, ``Datetime64TZDtype``, ``PeriodDtype``) to integer dtypes, use ``values.view(...)`` instead (:issue:`38544`) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
casting -> astype
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will update
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
updated+green
@@ -48,15 +49,17 @@ def test_astype_conversion(self): | |||
tm.assert_index_equal(result, expected) | |||
|
|||
idx = period_range("1990", "2009", freq="A", name="idx") | |||
result = idx.astype("i8") | |||
with tm.assert_produces_warning(FutureWarning, check_stacklevel=False): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for a lot of these you can just change the test if you want to use view
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
changed one of these, the rest were specifically targeting astype and not worth mucking with
do we have sufficient |
looks decent, yah |
I ran into this case of datetime->integer casting while exploring our casting rules (#22384). @jbrockmendel do you remember the rationale for deprecating this casting? It's not really clear to me why we would in the future disallow datetimelike->integer casting. This PR doesn't seem to give much reasoning, and the referenced issue is about the bitwidth / sign being ignored, but not sure deprecating altogether is necessarily the fix for that (the bitwidth being ignored also applies for integer->integer casting, which we didn't deprecate). |
|
Whoops, sorry, I totally forgot I already asked / you answered in the other thread .. :) Will continue there |
black pandas
git diff upstream/master -u -- "*.py" | flake8 --diff
Sits on top of #38535